package cn.com.tuns.assess.qsb.frame.ui;

import android.app.Application;
import android.content.Context;
import android.util.Log;
import cn.com.tuns.assess.qsb.frame.util.LogUtil;
import com.tencent.smtt.export.external.TbsCoreSettings;
import com.tencent.smtt.sdk.QbSdk;

import java.util.HashMap;

public class MyApplication extends Application {

    public static MyApplication context;


    @Override
    public void onCreate() {
        super.onCreate();
        context=this;


        AppManage.readLoginData();

        //异常上传
        MyCrashHanlder crashHandler = MyCrashHanlder.getInstance();
        // 注册crashHandler
        crashHandler.init(getApplicationContext());
        LogUtil.postAllErrorLog();



    }

    public void init(){
        AppManage.checkDbSys();
        AppManage.checkDBVersion(AppManage.getRootPath(), AppManage.setDB);

        HashMap map = new HashMap();
        map.put(TbsCoreSettings.TBS_SETTINGS_USE_SPEEDY_CLASSLOADER, true);
        map.put(TbsCoreSettings.TBS_SETTINGS_USE_DEXLOADER_SERVICE, true);
        QbSdk.initTbsSettings(map);
        QbSdk.PreInitCallback cb = new QbSdk.PreInitCallback() {

            @Override
            public void onViewInitFinished(boolean arg0) {
                // TODO Auto-generated method stub
                //x5內核初始化完成的回调，为true表示x5内核加载成功，否则表示x5内核加载失败，会自动切换到系统内核。
                Log.d("app", " onViewInitFinished is " + arg0);
            }

            @Override
            public void onCoreInitFinished() {
                // TODO Auto-generated method stub
            }
        };
        //x5内核初始化接口
        QbSdk.initX5Environment(getApplicationContext(),  cb);
    }

    public static Context getContext() {
        return context;
    }

}
